package com.med.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

import java.util.concurrent.Executors;

/**
 * Redis配置（独立配置监听容器，不依赖若依默认RedisConfig）
 */
@Configuration
public class RedisConfig {

    // 仅配置Redis消息监听容器，序列化使用若依默认的RedisTemplate
    @Bean
    public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory factory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(factory);
        container.setTaskExecutor(Executors.newFixedThreadPool(2));
        return container;
    }
}